<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>练习</title>
</head>
<body>
<!--     <button id="btn" onclick="showMessage()">哈哈哈</button>
    <script>
        //var btn = document.getElementById('btn'); //事件源
        //.onclick 事件类型   function(){} 事件处理程序
        function showMessage() {
            alert("hahahah");
        }
    </script> -->

    <!-- 按钮显示当前时间 -->
<!--     <button id="btn">时间</button>
    <div id="time"></div>
    <script>
        var btn = document.getElementById('btn');
        var time = document.getElementById('time');

        function getDate() {
            var date = new Date();
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var dates = date.getDate();
            var day = date.getDay();
            var arr = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
            return ('现在是' + year + '年' + month + '月' + dates + '日 ' + arr[day]);
        }
        btn.onclick = function() {
            time.innerHTML = getDate();
        }
    </script> -->

<!--     <button id="women">女</button>
    <button id="man">男</button> <br>
    <img src="" alt="">

    <script>
        var btnwm = document.getElementById('women');
        var btnm = document.getElementById('man');
        var img = document.querySelector('img');

        btnwm.onclick = function() {
            img.src = 'images/women.jpg';
        }
        btnm.onclick = function() {
            img.src = 'images/man.jpg';
        }
    </script> -->

    <!-- 根据当前时间显示问候语 -->
<!--     <div id="time" style="background-color: hotpink; height: 100px; width: 100px; color: white;"></div>
    <script>
        var time = document.getElementById('time');

        function judgeTime() {
            var date = new Date();
            var h = date.getHours();
            var time = '';
            console.log(h);

            if (h>=5 && h<13)
                time = '上午好';
            else if (h>=13 && h<18)
                time = '下午好';
            else if (h>18 || h<5)
                time = '晚上好';
            
            return time;
        }

        time.innerHTML = judgeTime(); -->

        
    </script>
</body>
</html>